package cloud.shyidong.admin.tentant.controller;

import cloud.shyidong.admin.tenant.service.TenantProjectService;
import cloud.shyidong.core.controller.AbstractController;
import cloud.shyidong.core.request.LongIdRequest;
import cloud.shyidong.tenant.dao.TenantProjectDao;
import cloud.shyidong.tenant.entity.TenantProjectEntity;
import cloud.shyidong.tenant.request.TenantProjectInsertRequest;
import cloud.shyidong.tenant.request.TenantProjectPageRequest;
import cloud.shyidong.tenant.request.TenantProjectSaveRequest;
import cloud.shyidong.tenant.request.TenantProjectUpdateRequest;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 租户项目控制器
 * </p>
 *
 * @author syd
 * @since 2023-09-14 13:41:55
 */
@RestController
@RequestMapping("/tenant-project")
@Slf4j
public class TenantProjectController extends AbstractController<TenantProjectService, TenantProjectDao, TenantProjectEntity, LongIdRequest, TenantProjectInsertRequest, TenantProjectUpdateRequest, TenantProjectPageRequest> {
    
    @GetMapping("/get")
    public TenantProjectEntity getByTenantId(@Valid LongIdRequest longIdRequest) {
        if (log.isDebugEnabled()) {
            log.debug("get param >>> {}", JSON.toJSONString(longIdRequest));
        }
        return getService().getByTenantId(longIdRequest.getId());
    }
    
    @PostMapping("/save")
    public TenantProjectEntity save(@RequestBody @Valid TenantProjectSaveRequest tenantProjectSaveRequest) {
        if (log.isDebugEnabled()) {
            log.debug("save param >>> {}", JSON.toJSONString(tenantProjectSaveRequest));
        }
        return getService().save(tenantProjectSaveRequest);
    }
    
}

